class Bus {
  constructor() {
    this.callBack = {}
  }
  $on(eventName, fn) {
    this.callBack[eventName] = this.callBack[eventName] || []
    this.callBack[eventName].push(fn)
  }

  $emit(eventName, ...args) {
    if (this.callBack[eventName]) {
      this.callBack[eventName].forEach(cb => cb(...args))
    }
  }

  $off(eventName) {
    if (this.callBack[eventName]) {
      this.callBack[eventName] = []
    }
  }
}
export default Bus
